import { TbUser } from '../../entities/TbUser';

export interface SaveUserDataResponse {
  id: number;
  realName: string;
  nickName: string;
  age: number;
  address: string;
}

// 对返回数据进行加工处理
export class UserDetailResponse {
  id: number;
  address: string;
  realName: string;
  nickName: string;
  age: number;

  constructor(data: TbUser) {
    if (!data) {
      return null;
    }
    this.address = data.address;
    this.realName = data.realName;
    this.nickName = data.nickName;
    this.age = data.age;
  }
}

export interface UserDataRow {
  id: number;
  address: string;
  realName: string;
  nickName: string;
  age: number;
}

export class UserListResponse {
  list: UserDataRow[];

  constructor(dataList: TbUser[]) {
    if (!dataList) {
      return null;
    }
    this.list = [];
    for (const data of dataList) {
      let tmp: UserDataRow = {
        id: data.id,
        address: data.address,
        realName: data.realName,
        nickName: data.nickName,
        age: data.age,
      };
      this.list.push(tmp);
    }
  }
}
